package com.movitech.mobile.cz.base.sys.bizcontroller;

import com.movitech.mobile.cz.base.modules.config.ArticleTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.sys.bizvo.UserRequestVO;
import com.movitech.mobile.cz.base.sys.entity.SysUser;
import com.movitech.mobile.cz.base.sys.service.SArticleService;
import com.movitech.mobile.cz.base.sys.service.SysUserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * Created by Administrator on 2018/3/1.
 */
@RestController
@RequestMapping("/v1/register/public")
@Api(value = "采购外网平台注册接口", description = "采购外网平台注册接口")
public class RegisterController {

    @Autowired
    private SArticleService sArticleService;

    /***
     * 供方-注册须知
     * @return
     */
    @GetMapping("/getRegistrationPolicy")
    @ApiOperation(
            value = "注册须知",
            notes = "注册须知",
            response = Boolean.class
    )
    public RestReturnResult<Object> getRegistrationPolicy() {
        RestReturnResult<Object> hResult=RestReturnResult.success();
        try {
            hResult=sArticleService.getSArticleByType(ArticleTypeEnum.articleType2.getCode());
        }catch (RuntimeException e){
            e.printStackTrace();
            hResult=RestReturnResult.error();
        }
        return hResult;
    }

//    @PostMapping("/supplierRegister")
//    @ApiOperation(
//            value = "供方注册",
//            notes = "供方注册",
//            response = Boolean.class
//    )
//    public RestReturnResult supplierRegister(@RequestBody UserRequestVO userRequestVo) {
//        RestReturnResult restReturnResult=RestReturnResult.error();
//        SysUser sysUser=sysUserService.getSysUserByUserName(userRequestVo.getUserName());
//        if(sysUser==null){
//            RestReturnResult<SysUser> result=sysUserService.saveUserRequestVo(userRequestVo);
//            if(result!=null&& CommonConstants.SUCCESS.equals(result.getCode()))
//                restReturnResult=new RestReturnResult(CommonConstants.SUCCESS,"注册成功");
//            else restReturnResult=new RestReturnResult(CommonConstants.FAIL,"系统错误！");
//        }else{
//        	restReturnResult=new RestReturnResult(CommonConstants.FAIL,"用户名已存在");
//        }
//        return restReturnResult;
//    }

}
